﻿@using STX.Domain
@using STX.Web.Framework.Security
@model STX.Web.Framework.Query.PagedList<STX.Domain.BizActivity>
@{
    ViewBag.Title = "Query";
    Layout = null;
    STX.Domain.TabAdministrator CurUser = ViewBag.CurUser;
}
<div class="pageContent" ratio="*">
    <div class="grid">
        <table class="table" width="100%" layoutH="138" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th width="22">
                        <input type="checkbox" group="ids" class="checkboxCtrl" />
                    </th>
                    <th width="100">
                        所属项目
                    </th>
                    <th width="200">
                        活动名称
                    </th>
                    <th width="150">
                        活动时间
                    </th>
                    <th>
                        活动地点
                    </th>
                    <th>
                        报价制表人
                    </th>
                    <th>
                        执行
                    </th>   
                    <th>
                        状态
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Data)
                {
                    <tr>
                        <td style="text-align: center">
                            <input name="ids" value="@item.Id" type="checkbox" />
                        </td>
                        <td>@item.BizProject.Name
                        </td>
                        <td>@item.Name
                        </td>
                        <td>@item.StartTime.ToString("yyyy-M-d") - @item.EndTime.ToString("yyyy-M-d")
                        </td>
                        <td>
                            @item.Place
                        </td>
                        <td>
                            @item.QuotationTabulator（@item.QuotationGeneratedTime.ToString("yyyy-M-d")）
                        </td>
                        <td>
                            @item.Executor
                        </td>
                        <td>@item.Step.GetFiledName()（@item.Auditing.GetFiledName()）</td>
                        <td>
                            @{
                                //执行制作报价阶段
                                if (item.Step == StepEnum.制作报价 && CurUser.Position.CheckRights(RightsEnum.制作报价))
                                {
                                        if (item.Auditing == AuditingEnum.草稿)
                                        {
                                            <a href="@Url.Action("editquote",new {id=item.Id})" target="dialog" width="1000" 
                                            height="500" backtype="html" refreshonclose="true">编辑报价</a>
                                        }
                                        if (item.Auditing == AuditingEnum.审核失败)
                                        {
                                            <a href="@Url.Action("editquote", new { id = item.Id })" target="dialog" width="1000" 
                                            height="500" backtype="html" refreshonclose="true">编辑报价</a>
                                            <a href="@Url.Action("editquote", new { id = item.Id })" target="dialog" width="1000" 
                                            height="500" backtype="html" refreshonclose="true">删除重建</a>
                                        }
                                }

                                if (item.Step == StepEnum.项目经理审核报价 && CurUser.Position.CheckRights(RightsEnum.制作报价))
                                {
                                    if (item.Auditing == AuditingEnum.待审核)
                                    {
                                        <a href="@Url.Action("withdrawquote", new { id = item.Id })" target="ajax" backtype="refresh" postdata="{}">撤回报价</a>
                                    }
                                }

                                if (item.Step == StepEnum.项目经理审核报价 && CurUser.Position.CheckRights(RightsEnum.审核报价))
                                {
                                    if (CurUser.Position == PositionEnum.ProjectManager || CurUser.Position == PositionEnum.SystemPower)
                                    {
                                        if (item.Auditing == AuditingEnum.待审核)
                                        {
                                            <a href="@Url.Action("editquote", new { id = item.Id })" target="dialog" width="1000" 
                                               height="500" backtype="html" refreshonclose="true">审核报价</a>
                                        }
                                        if (item.Auditing == AuditingEnum.审核失败)
                                        {
                                            <a href="@Url.Action("editquote", new { id = item.Id })" target="dialog" width="1000" 
                                               height="500" backtype="html" refreshonclose="true">被退回</a>
                                        }
                                    }
                                }

                                if (item.Step == StepEnum.项目总监审核报价 && CurUser.Position.CheckRights(RightsEnum.审核报价))
                                {
                                    if (CurUser.Position == PositionEnum.CPO || CurUser.Position == PositionEnum.SystemPower)
                                    {
                                        if (item.Auditing == AuditingEnum.待审核)
                                        {
                                            <a href="@Url.Action("editquote", new { id = item.Id })" target="dialog" width="1000" 
                                               height="500" backtype="html" refreshonclose="true">审核报价</a>
                                        }
                                    }
                                }
                                if (item.Step == StepEnum.制作成本 && CurUser.Position.CheckRights(RightsEnum.制作项目成本))
                                {
                                    if (item.Auditing == AuditingEnum.待审核)
                                    {
                                         <a href="@Url.Action("editcost", new { id = item.Id })" target="dialog" width="1100" 
                                               height="500" backtype="html" refreshonclose="true">制作成本</a>
                                    }
                                    if (item.Auditing == AuditingEnum.审核失败
                                        || item.Auditing == AuditingEnum.草稿)
                                    {
                                         <a href="@Url.Action("editcost", new { id = item.Id })" target="dialog" width="1100" 
                                               height="500" backtype="html" refreshonclose="true">修改成本</a>
                                    }
                                }
                                
                                
                                if (item.Step == StepEnum.项目总监审核成本 && CurUser.Position.CheckRights(RightsEnum.审核项目成本))
                                {
                                    if (CurUser.Position == PositionEnum.CPO || CurUser.Position == PositionEnum.SystemPower)
                                    {
                                        if (item.Auditing == AuditingEnum.待审核)
                                        {
                                            <a href="@Url.Action("editcost", new { id = item.Id })" target="dialog" width="1100" 
                                               height="500" backtype="html" refreshonclose="true">审核成本</a>
                                        }
                                    }
                                }
                                if (item.Step == StepEnum.财务经理审核成本 && CurUser.Position.CheckRights(RightsEnum.审核项目成本))
                                {
                                    if (CurUser.Position == PositionEnum.FinancialManager || CurUser.Position == PositionEnum.SystemPower)
                                    {
                                        if (item.Auditing == AuditingEnum.待审核)
                                        {
                                            <a href="@Url.Action("editcost", new { id = item.Id })" target="dialog" width="1100" 
                                               height="500" backtype="html" refreshonclose="true">审核成本</a>
                                        }
                                    }
                                }
                                if (item.Step == StepEnum.财务经理制作成本 && CurUser.Position.CheckRights(RightsEnum.制作财务成本))
                                {
                                    if (item.Auditing == AuditingEnum.待审核)
                                    {
                                         <a href="@Url.Action("editfinance", new { id = item.Id })" target="dialog" width="1250" 
                                               height="500" backtype="html" refreshonclose="true">财务审核</a>
                                    }
                                    if (item.Auditing == AuditingEnum.审核失败
                                        || item.Auditing == AuditingEnum.草稿)
                                    {
                                         <a href="@Url.Action("editfinance", new { id = item.Id })" target="dialog" width="1250" 
                                         height="500" backtype="html" refreshonclose="true">修改成本</a>
                                    }
                                }
                                if (item.Step == StepEnum.财务总监审核成本 && CurUser.Position.CheckRights(RightsEnum.审核财务成本))
                                {
                                    if (item.Auditing == AuditingEnum.待审核)
                                    {
                                         <a href="@Url.Action("editfinance", new { id = item.Id })" target="dialog" width="1250" 
                                               height="500" backtype="html" refreshonclose="true">审核成本</a>
                                    }

                                    if (item.Auditing == AuditingEnum.审核失败)
                                    {
                                         <a href="@Url.Action("editfinance", new { id = item.Id })" target="dialog" width="1250" 
                                               height="500" backtype="html" refreshonclose="true">被退回</a>
                                    }

                                }
                                if (item.Step == StepEnum.总经理审核成本 && CurUser.Position.CheckRights(RightsEnum.审核财务成本))
                                {
                                    if (item.Auditing == AuditingEnum.待审核)
                                    {
                                         <a href="@Url.Action("editfinance", new { id = item.Id })" target="dialog" width="1250" 
                                               height="500" backtype="html" refreshonclose="true">审核成本</a>
                                    }

                                }

                                if (item.Step != StepEnum.制作报价
                                    && item.Step != StepEnum.项目经理审核报价
                                    && item.Step != StepEnum.项目总监审核报价)
                                {
                                    <a href="@Url.Action("PrintQuotePrice", new { id = item.Id })" target="navtab">打印报价</a>
                                }

                                if ((int)item.Step > (int)StepEnum.总经理审核成本
                                    || (item.Step == StepEnum.总经理审核成本 && item.Auditing == AuditingEnum.审核成功))
                                {
                                    <a href="@Url.Action("PrintCost", new { id = item.Id })" target="navtab">打印成本</a>
                                }
                            }
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>
@Html.Partial("~/Administrator/Views/Shared/Pager.cshtml", new STX.Admin.Models.PagerModel { Page = Model.Page, Total = Model.Total, PageSize = Model.PageSize })
